#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys

def collect(file):
    fp = open(file, 'r')
    result = {}
    for line in fp:
        num, keyword = line.split()
        if keyword in result:
            result[keyword].append(num)
        else:
            result[keyword] = [num]
    return result

if __name__ == '__main__':
    result = collect(sys.argv[1])
    for key in sorted(result.keys()):
        print '%s: %s' % (key, ','.join(result[key]))
    
